package org.cying.main.util;

import cn.hutool.core.date.DateUtil;
import org.cying.main.domain.TimeState;

/**
 * 全局方法库
 * @author Cying
 */
public class Method {

    /**
     * 获取指定时间段的时间段信息
     * @return 指定时间的时间段信息
     */
    public static TimeState getTime() {

        double time = DateUtil.thisHour(true) + DateUtil.thisMinute() / 100.0;

        if (time < TimeVariable.beginMorning1) {
            return new TimeState(TimeVariable.beginMorning1 + "0 开始签到", -1);
        }
        else if (time >= TimeVariable.beginMorning1 && time <= TimeVariable.endMorning1) {
            return new TimeState("上午一二节课", 1);
        }
        else if (time > TimeVariable.endMorning1 && time < TimeVariable.beginMorning2) {
            return new TimeState(TimeVariable.beginMorning2 + "0 开始签到", -2);
        }
        else if (time >= TimeVariable.beginMorning2 && time <= TimeVariable.endMorning2) {
            return new TimeState("上午三四节课", 2);
        }
        else if (time > TimeVariable.endMorning2 && time < TimeVariable.beginAfter1) {
            return new TimeState(TimeVariable.beginAfter1 + "0 开始签到", -3);
        }
        else if (time >= TimeVariable.beginAfter1 && time <= TimeVariable.endAfter1) {
            return new TimeState("下午一二节课", 3);
        }
        else if (time > TimeVariable.endAfter1 && time < TimeVariable.beginAfter2) {
            return new TimeState(TimeVariable.beginAfter2 + "0 开始签到", -4);
        }
        else if (time >= TimeVariable.beginAfter2 && time <= TimeVariable.endAfter2) {
            return new TimeState("下午三四节课", 4);
        }
        else {
            return new TimeState("今天签到已结束",0);
        }
    }

}
